package cn.itcast.web.controller.stat;

import cn.itcast.stat.StatService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("stat")
public class StatController {

    @Reference
    private StatService statService;

    /**
     * 请求路径： /stat/toCharts.do
     * 参数：chartsType
     */
    /**
     * 点击统计分析模块，进入对应的页面
     * 生产厂家销售统计：http://localhost:8080/stat/toCharts.do?chartsType=factory
     * 产品销售排行：   http://localhost:8080/stat/toCharts.do?chartsType=sell
     * 系统访问压力图： http://localhost:8080/stat/toCharts.do?chartsType=online
     */
    @RequestMapping("toCharts")
    public String toCharts(String chartsType){

        return "stat/stat-"+chartsType;
    }


    /**
     * 生产厂家销售统计，返回页面需要的json数据
     */
    @RequestMapping("getFactoryData")
    @ResponseBody
    public List<Map<String, Object>>  getFactoryData(){
        List<Map<String, Object>> list = statService.getFactoryData();
        return list;
    }



    @RequestMapping("getProductData")
    @ResponseBody
    public List<Map<String, Object>>  findProductData(){
        List<Map<String, Object>> list = statService.findProductData(5);
        return list;
    }



    @RequestMapping("findOnline")
    @ResponseBody
    public List<Map<String, Object>>  findOnline(){

        return statService.findOnline();

    }

}
